package com.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ImageMapperConfig implements WebMvcConfigurer {

    @Value("${dy.home}")
    private String upload;

    @Value("${dy.tmp}")
    private String tmp ;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //

         ///home/images/upload/dy
        ///upload/dy/1605064060713.png
         registry.addResourceHandler("/upload/**").addResourceLocations("file:" + upload + "images/upload/");
         registry.addResourceHandler("/dy/**").addResourceLocations("file:" + upload+"dy/");
         registry.addResourceHandler("/apk/**").addResourceLocations("file:" + upload + "apk/");
        registry.addResourceHandler("/images/**").addResourceLocations("file:" + upload + "images/");
        // 临时目录添加访问映射
        //registry.addResourceHandler("/tmp/**").addResourceLocations("file:" + tmp );
    }
}
